package logic

import (
	"cart_srv/cart"
	"cart_srv/internal/svc"
	"cart_srv/model/mysql"
	"context"

	"github.com/zeromicro/go-zero/core/logx"
)

type ExistCartGoodsLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewExistCartGoodsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ExistCartGoodsLogic {
	return &ExistCartGoodsLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *ExistCartGoodsLogic) ExistCartGoods(in *cart.ExistCartGoodsRequest) (*cart.ExistCartGoodsResponse, error) {
	// todo: add your logic here and delete this line
	c := mysql.Cart{
		UserID:  uint(in.UserId),
		GoodsID: in.GoodsId,
	}
	return &cart.ExistCartGoodsResponse{
		Exist: c.Exist(),
	}, nil
}
